package leetcode.tree;

public class LeeCode111_MinDepth {
    public int minDepth(TreeNode root) {
        if (root == null) {
            return 0;
        }

        if (root.left == null && root.right == null) {
            return 1;
        }
        int ldeep = Integer.MAX_VALUE;
        int rdeep = Integer.MAX_VALUE;
        if (root.left != null) {
            ldeep = minDepth(root.left);
        }

        if (root.right != null) {
            rdeep = minDepth(root.right);
        }

        return Math.min(ldeep, rdeep) + 1;
    }
}
